package com.google.gwt.livinglife.server.data;

import java.util.Date;
import javax.jdo.annotations.IdentityType;
import javax.jdo.annotations.Inheritance;
import javax.jdo.annotations.InheritanceStrategy;
import javax.jdo.annotations.PersistenceCapable;
import javax.jdo.annotations.IdGeneratorStrategy;
import javax.jdo.annotations.Persistent;
import javax.jdo.annotations.PrimaryKey;
import com.google.appengine.api.datastore.Text;
import com.google.appengine.api.datastore.Link;
import com.google.gwt.livinglife.client.data.BasicPostData;

@PersistenceCapable(identityType = IdentityType.APPLICATION)
@Inheritance(strategy = InheritanceStrategy.SUBCLASS_TABLE)
public abstract class BasicPost {
	@PrimaryKey
  @Persistent(valueStrategy = IdGeneratorStrategy.IDENTITY)
  private Long id;
  
  @Persistent
	private Text post_text;
	
  @Persistent
  private Date creation_date;
	
  @Persistent
  private String author_id;
	
  @Persistent
  private String author;
  
  @Persistent
  private Link embeded_image;

	public BasicPost() {
	}
	
	public BasicPost(BasicPostData data) {
		post_text = new Text(data.getPost_text());
		creation_date = new Date();
		author_id = data.getAuthor().getId();
		author = data.getAuthor().getNickname();
		embeded_image = new Link(data.getEmbeded_image());
	}

  public Text getPost_text() {
		return post_text;
	}
		
	public void setPost_text(Text postText) {
		post_text = postText;
	}
	
	public String getAuthor() {
		return author;
	}
	
	public Long getId() {
		return id;
	}
	
	public void setAuthor(String author) {
		this.author = author;
	}
	
	public Link getEmbeded_image() {
		return embeded_image;
	}
	
	public void setEmbeded_image(Link embededImage) {
		embeded_image = embededImage;
	}
	
	public Date getCreation_date() {
		return creation_date;
	}

	public void setAuthor_id(String author_id) {
		this.author_id = author_id;
	}

	public String getAuthor_id() {
		return author_id;
	}
}
